package com.jz.community.modulemine.money.ui.adapter;

import android.support.annotation.Nullable;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.jz.community.modulemine.R;
import com.jz.community.modulemine.money.bean.MoneyDetailBean;

import java.util.List;


/**
 * Created by Ani_H on 2018/1/11.
 */

public class MoneyDetailAdapter extends BaseQuickAdapter<MoneyDetailBean.EmbeddedBean.CardPackageLogsBean, BaseViewHolder> {


    public MoneyDetailAdapter(int layoutResId, @Nullable List<MoneyDetailBean.EmbeddedBean.CardPackageLogsBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, MoneyDetailBean.EmbeddedBean.CardPackageLogsBean entity) {
        int status = entity.getStatus();// 消费状态0-支出 1-收入
        int type = entity.getType();//充值方式 1-微信充值 2-支付宝充值 3-兑换码充值 4-线上支付 5-活动赠送

        TextView typeName = helper.getView(R.id.item_money_name);

//        1-微信充值
//        2-支付宝充值
//        3-兑换码充值
//        4-线上支付(status=0:线上支付 status=1:线上退款)
//        5-活动赠送
//        6-系统充值(status=0:系统充值 status=1:系统撤销)
//        7-话费充值(status=0:话费充值 status=1:话费退款)
//        8-壳牌(status=0:壳牌消费 status=1:壳牌撤销)

        if (type == 1) {
            typeName.setText("微信充值");
        } else if (type == 2) {
            typeName.setText("支付宝充值");
        } else if (type == 3) {
            typeName.setText("兑换码充值");
        } else if (type == 4) {
            if (status == 0) {
                typeName.setText("线上支付");
            } else {
                typeName.setText("线上退款");
            }
        } else if (type == 5) {
            typeName.setText("活动赠送");
        } else if (type == 6) {
            if (status == 0) {
                typeName.setText("系统充值");
            } else {
                typeName.setText("系统撤销");
            }
        } else if (type == 7) {
            if (status == 0) {
                typeName.setText("话费充值");
            } else {
                typeName.setText("话费退款");
            }
        } else if (type == 8) {
            if (status == 0) {
                typeName.setText("壳牌消费");
            } else {
                typeName.setText("壳牌撤销");
            }
        }

        TextView money = helper.getView(R.id.item_money_num);


        if (status == 0) {
            //支出
            money.setTextColor(mContext.getResources().getColor(R.color.font_gary));
            money.setText("-" + entity.getAmount());
        } else if (status == 1) {
            //收入
            money.setText("+" + entity.getAmount());
            money.setTextColor(mContext.getResources().getColor(R.color.home_red));
        }

        helper.setText(R.id.item_money_time, entity.getCreateDate());

    }
}
